<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>SplitContainer Demo</title>
        <style type="text/css">
            @import "../dojo-release-1.0.0/dijit/themes/tundra/tundra.css";
            @import "../dojo-release-1.0.0/dojo/resources/dojo.css";
        </style>
        <script type="text/javascript" src="../dojo-release-1.0.0/dojo/dojo.js"
                djConfig="parseOnLoad: true, isDebug: true"></script>
        
        <script>
            dojo.require("dojo.data.ItemFileReadStore");
            dojo.require("dojo.data.ItemFileWriteStore");
            dojo.require("dijit.layout.SplitContainer");
            dojo.require("dijit.layout.ContentPane");
            dojo.require("dijit.Tree");
            dojo.require("dojo.parser");
            dojo.require("dijit._tree.dndSource");
            dojo.require("dijit.layout.TabContainer");
            dojo.require("dijit.form.Button");
            
            
        </script>
        <script type="text/javascript" src="../js/soapclient.js">
        </script>
        <script type="text/javascript"> 
         
              
                   function init(){
                     var poptarts ={ label:'name',identifier:'eId',attribute: "children",items:[{ name:'treeRoot', type:'category',eId:'0'}]};
                var popStore = new dojo.data.ItemFileWriteStore({data: poptarts});
                 var _tree=new dijit.Tree({
                id:'tree',
                store:popStore,
                query:{type:'category'},
                labelAttr:"name",childrenAttr:"children,items" ,
                typeAttr:"type"},dojo.byId("tree"));
                   
                   
                //添加区域结点
                var data =new Array();
                var url = "http://localhost:8080/logistics-ws/services/BasicManageService";
                var pl = new SOAPClientParameters();
                pl.add('eType','1') ;
                SOAPClient.invoke(url, "getEnumerationByType", pl, false,  function GetEnu_callBack(ul, soapResponse){
                    ul=ul.out;
                    for(var i = 0; i < ul.length; i++){		
                        // data[i]= {name: ul[i].fieldName,type:ul[i].enumerationType, eId:ul[i].id};
                        data[i]= {label:ul[i].fieldName,attribute: "children",item:{name: ul[i].fieldName,type:ul[i].enumerationType ,eId:ul[i].id}};
                    }
                }
            );
            var _tree=dijit.byId("tree");
            
            var children0Array=_tree.getChildren();
            alert(children0Array.length);
            var ch0Node =children0Array[0];
            //alert(_tree.getLabel(children0Array[0]));
            ch0Node._addChildren(data);
          
            //添加省份结点
            var chitem;
            var chdata =new Array();
            
            //  var ch2item =new Array();
           var childrenArray1=ch0Node.getChildren();
            for (var i=0; i<childrenArray1.length; i++){	
                var p2 = new SOAPClientParameters();
                //p2.add('parentType','1') ;
                var chNode =childrenArray1[i];
                chitem=chNode.item;
               
                for(var t in chitem){
                    console.debug(t+":"+chitem[t]);
                }
                //p2.add('eType',chitem.eId) ;
                p2.add('eType','2') ;
                SOAPClient.invoke(url, "getEnumerationByType", p2 ,false,  function GetEnu_callBack(ul1, soapResponse){  
                    ul1=ul1.out;
                    for(var ii = 0; ii < ul1.length; ii++){		
                        chdata[ii]= {label:ul1[ii].fieldName,attribute: "children",item: {name: ul1[ii].fieldName,type:ul1[ii].enumerationType ,eId:ul1[ii].id}};
                        //alert("chNode.getChildren()[i]=="+chNode.getChildren()[i]);
                        // ch2item[i]=chNode.getChildren()[i];
                    }
                    chNode._addChildren(chdata);
                   
                    var  ch2item=chNode.getChildren();
                    
                    for (var iii=0; iii<ch2item.length; iii++){
                        var ch2data =new Array();
                        var p3 = new SOAPClientParameters();
                        
                        p3.add('eType','3') ;
                        SOAPClient.invoke(url, "getEnumerationByType", p3 ,false,  function GetEnu_callBack(ul2, soapResponse){  
                            ul2=ul2.out;
                            for(var j = 0; j < ul2.length; j++){		
                                ch2data[j]= {label:ul2[j].fieldName,attribute: "children", item: {name: ul2[j].fieldName,type:ul2[j].enumerationType ,eId:ul2[j].id}};
                            }});
                            var ch2Node= ch2item[iii];
                            ch2Node._addChildren(ch2data);
                        }
                        //添加城区结点end   
                    });
                }
            }
            
            
            dojo.addOnLoad(init);
              
        </script>
    </head>
    <body class="tundra">
        
        
        <div dojoType="dijit.layout.SplitContainer"
             orientation="horizontal"
             sizerWidth="7"
             activeSizing="true"
             style="border: 1px solid #bfbfbf; width: 1260px; height: 840px;">
            
            
            <div dojoType="dijit.layout.ContentPane" sizeMin="20" sizeShare="20" >
                
                 <div id="tree"  ></div> 
            </div>
            <div dojoType="dijit.layout.ContentPane" sizeMin="50" sizeShare="50">
                
                <div id="mainTabContainer" dojoType="dijit.layout.TabContainer"
                     style="width:500px;height:100px">
                    <div id="LittleRed" dojoType="dijit.layout.ContentPane" title="地点">
                        Once upon a time there was a dear little girl who was loved by
                        every one who looked at her, but most of all by her grandmother,
                        and there was nothing that she would not have given to the child.
                    </div>
                    <div id="HanselGretel" dojoType="dijit.layout.ContentPane"
                         title="路线" closable="true" selected="true">
                        Hard by a great forest dwelt a poor wood-cutter with his wife
                        and his two children. The boy was called Hansel and the girl Gretel.
                        He had little to bite and to break, and once when great dearth fell
                        on the land, he could no longer procure even daily bread.
                    </div>
                    
                </div>
                
                
            </div>
        </div>
        
    </body>
    
    
</html>

